import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.SchedulerFactory;
import org.quartz.Trigger;
import org.quartz.impl.StdSchedulerFactory;
import static org.quartz.JobBuilder.newJob;
import static org.quartz.SimpleScheduleBuilder.simpleSchedule;
import static org.quartz.TriggerBuilder.newTrigger;

public class QuartzSchedulerDemo {

	public static void main(String[] args) {
		JobDetail demoJob = newJob(DemoJob.class)
			    .build();
			 
			  Trigger trigger = newTrigger()
			    .withIdentity("SandeepDemoTrigger")
			    .withSchedule(
			      simpleSchedule().withIntervalInSeconds(3)
			        .repeatForever()).build();
			 
			  SchedulerFactory sf = new StdSchedulerFactory();
			  Scheduler sched;
			  try {
			   sched = sf.getScheduler();
			   sched.scheduleJob(demoJob, trigger);
			   sched.start();
			 
			  } catch (SchedulerException e) {
			   e.printStackTrace();
			  }

	}

}
